package com.blogs.tools;

import com.blogs.entity.AppConfig;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class DBSharedPreferences {
	//DBSharedPreferences工具类
	SharedPreferences sp;
	Editor spEd;
	public DBSharedPreferences(Context context)
	{
		sp =context.getSharedPreferences(AppConfig.SHARED_PREFERENCES, 0);
		spEd = sp.edit();
	}
	/*---begin频道----*/
	public void SetChannelIndex(int value)
	{
		spEd.putInt(AppConfig.CHANNEL_INDEX, value);
		spEd.commit();
	}
	public int GetChannelIndex()
	{
		return sp.getInt(AppConfig.CHANNEL_INDEX, 0);
	}
	/*---end频道----*/
	
	/*-----是否打开图片浏览------*/
	public void SetIsShowPic(boolean value)
	{
		spEd.putBoolean(AppConfig.IS_SHOW_PIC, value);
		spEd.commit();
	}
	public boolean GetIsShowPic()
	{
		return sp.getBoolean(AppConfig.IS_SHOW_PIC,false);
	}
	/*是否打开图片浏览*/
	
	/*----是否开启全屏----*/
	public void SetIsFullScreen(boolean value)
	{
		spEd.putBoolean(AppConfig.IS_FULL_SCREEN, value);
		spEd.commit();
	}
	public boolean GetIsFullScreen()
	{
		return sp.getBoolean(AppConfig.IS_FULL_SCREEN,false);
	}
	/*----是否开启全屏----*/
	/*----是否开夜间模式----*/
	public void SetIsDarkState(boolean value)
	{
		spEd.putBoolean(AppConfig.IS_DARK_STATE, value);
		spEd.commit();
	}
	public boolean GetIsDarkState()
	{
		return sp.getBoolean(AppConfig.IS_DARK_STATE,false);
	}
	/*----是否开夜间模式----*/
	/*----博客正文字体大小----*/
	public void SetTextSize(int value)
	{
		spEd.putInt(AppConfig.CUR_TEXT_SIZE, value);
		spEd.commit();
	}
	public int GetTextSize()
	{
		return sp.getInt(AppConfig.CUR_TEXT_SIZE,AppConfig.TEXT_SIZE_MIDDLE);
	}
	/*----博客正文字体大小----*/
	
	
	
	
	
	/*----用户登录用户名----*/
	public void SetUserName(String value)
	{
		spEd.putString(AppConfig.USER_NAME, value);
		spEd.commit();
	}
	public String GetUserName()
	{
		return sp.getString(AppConfig.USER_NAME,"");
	}
	/*----用户登录用户名----*/
	
	/*----用户SESSION_ID----*/
	public void SetSessionID(String value)
	{
		spEd.putString(AppConfig.SESSION_ID, value);
		spEd.commit();
	}
	public String GetSessionID()
	{
		return sp.getString(AppConfig.SESSION_ID,"");
	}
	/*----用户SESSION_ID----*/
	
	/*----用户昵称----*/
	public void SetNickName(String value)
	{
		spEd.putString(AppConfig.NICK_NAME, value);
		spEd.commit();
	}
	public String GetNickName()
	{
		return sp.getString(AppConfig.NICK_NAME,"");
	}
	/*----用户昵称----*/
	
	/*----用户ID----*/
	public void SetUserID(String value)
	{
		spEd.putString(AppConfig.USER_ID, value);
		spEd.commit();
	}
	public String GetUserID()
	{
		return sp.getString(AppConfig.USER_ID,"");
	}
	/*----用户ID----*/
	
	/*----用户头像----*/
	public void SetUserAvatar(String value)
	{
		spEd.putString(AppConfig.USER_AVATAR, value);
		spEd.commit();
	}
	public String GetUserAvatar()
	{
		return sp.getString(AppConfig.USER_AVATAR,"");
	}
	/*----用户头像----*/
	
	
	/*----是否有新的收藏文章----*/
	public void SetHasNewFavo(Boolean value)
	{
		spEd.putBoolean(AppConfig.HAS_NEW_FAVO, value);
		spEd.commit();
	}
	public boolean GetHasNewFavo()
	{
		return sp.getBoolean(AppConfig.HAS_NEW_FAVO,false);
	}
	/*----是否有新的收藏文章----*/
	
	/*--根据名称设置与获取字符串名字--*/
	public void SetStrVarValue(String name,String value)
	{
		spEd.putString(name,value);
		spEd.commit();
	}
	public String GetStrVarValue(String name)
	{
		return sp.getString(name, "");
	}
	/*--根据名称设置与获取字符串名字--*/
}
